<template>
  <Fragment>
    <div class="head-wrap borderBottom-1px">
      <div class="title left borderBottom-2px">{{title}}</div>
      <div class="operate right">                  
      </div>
    </div>
    <div class="content-wrap">
      <div class="chart-content" ref="prescriptionTrendStatistics">
        2019
      </div>                         
    </div>
    <img src="@/assets/images/card819.png" class="card819" alt="">
  </Fragment>
</template>

<script>
import * as echarts from 'echarts';
import 'echarts-liquidfill'
import { Fragment } from 'vue-fragment'
export default {
  name:'box-card-single-analysis2-baogaodanshulang',
  components:{Fragment},
  props:{
    title:{
      type:String
    }
  },
  mounted(){
    this.makeData()
  },
  methods:{
    makeData(){
    var datas = [{
          name: '装备制造',
          value: 54
      }, {
          name: '现代材料',
          value: 44
      }, {
          name: '新能源',
          value: 35
      }, {
          name: '新一代信息技术',
          value: 30
      }, {
          name: '现代材料2',
          value: 44
      }, {
          name: '新能源2',
          value: 35
      }, {
          name: '新一代信息技术2',
          value: 30
      }, {
          name: '商贸物流2',
          value: 20
      }]

      var titleArr = [],seriesArr = [],colors = [
          ['#389af4', '#dfeaff'],
          ['#ff8c37', '#ffdcc3'],
          ['#ffc257', '#ffedcc'],
          ['#fd6f97', '#fed4e0'],
          ['#a181fc', '#e3d9fe'],
          ['#389af4', '#dfeaff'],
          ['#ff8c37', '#ffdcc3'],
          ['#ffc257', '#ffedcc'],
          ['#fd6f97', '#fed4e0'],
          ['#a181fc', '#e3d9fe']
      ]
      datas.forEach(function(item, index) {
        titleArr.push({
            text: item.name,
            x: index > 3 ? (index - 4) * 20 + 20 + '%' : (index) * 20 + 20 + '%',
            y: index > 3 ? '85%' : '35%',
            // top: '65%',
            textAlign: 'center',
            textStyle: {
                fontWeight: 'normal',
                fontSize: '16',
                color: colors[index][0],
                textAlign: 'center',
            },
        });
        seriesArr.push({
            // name: item.name,
            type: 'pie',
            clockWise: false,
            radius: [30, 32],
            itemStyle: {
                normal: {
                    color: colors[index][0],
                    shadowColor: colors[index][0],
                    shadowBlur: 0,
                    label: {
                        show: false
                    },
                    labelLine: {
                        show: false
                    },
                }
            },
            hoverAnimation: false,
            center: [index > 3 ? (index - 4) * 20 + 20 + '%' : (index) * 20 + 20 + '%', index > 3 ? '65%' : '25%'],
            data: [{
                value: item.value,
                label: {
                    normal: {
                        formatter: function(params) {
                            return params.value + '%';
                        },
                        position: 'center',
                        show: true,
                        textStyle: {
                            fontSize: '20',
                            fontWeight: 'bold',
                            color: colors[index][0]
                        }
                    }
                },
            }, {
                value: 100 - item.value,
                name: 'invisible',
                itemStyle: {
                    normal: {
                        color: colors[index][1]
                    },
                    emphasis: {
                        color: colors[index][1]
                    }
                }
            }]
        })
      });
      const option11 = {
          backgroundColor: "",
          title: titleArr,
          series: seriesArr
      }
      this.makeGraph(this.$refs.prescriptionTrendStatistics,option11)
    },
    makeGraph(ref,option){
      let myChart=echarts.init(ref)
      myChart.setOption(option)
    }
  }
}
</script>
<style lang="less" scoped>
.left{float: left;}
.right{float: right;}
.borderBottom-1px{
  border-bottom: .01rem solid #7787C7 ;
}
.borderBottom-2px{
  border-bottom: .02rem solid #7787C7 ;
}
.head-wrap{
    font-size: .16rem;
    color:#ffffff;
    overflow: hidden;
    .title{
      height: .26rem;
      line-height: .262rem;
    }
    .operate{
      span{
        height: .26rem;
        line-height: .26rem;
        display: inline-block;
        cursor: pointer;
        background: url('~@/assets/images/671.png') no-repeat center center;
        background-size: contain;
        padding: 1px .2rem;
      }
      span.active{
        background: url('~@/assets/images/670.png') no-repeat center center;
        background-size: contain;
        padding: 1px .2rem;
      }
    }
  }
  .content-wrap{
    width: 100%;
    // height:calc( (100vh - 1.23rem) / 3 - .36rem) ;
    height:calc( (100vh - 1.23rem) * 4 / 10 - 0.4rem) !important;
    .chart-content{
      width: 100%;
      // height:calc( (100vh - 1.23rem) / 3 - .36rem) ;
      height:calc( (100vh - 1.23rem) * 4 / 10 - 0.4rem) !important;
      float: left;
      overflow: hidden;
    }
  }
  img{width: 100%;float: left;}
</style>